﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace demo2
{
    class student
    {
        public string num;
        public string name;
        public string sex;
        public int age;
        public string zhuan;

        public string Num
        {
            get
            {
                return num;

            }

            set
            {
                num = value;
            }
        }

        //Name属性对name字段进行封装
        public string Name
        {
            get
            {
                return name;

            }

            set
            {
                name = value;
            }
        }



        public string Sex {
            get {
                return sex;
            }
            set {
                sex = value;
            }
        }

        public int Age
        {
            get
            {
                return age;
            }
            set {
                if (value > 0 || value < 128)
                {
                    age = value;
                }
                else {
                    age = 0;
                }
            }
        }
        public string Zhuan
        {
            get
            {
                return zhuan;

            }

            set
            {
                zhuan = value;
            }
        }
        public void b()
        {
            Console.WriteLine("姓名：" + name);
            Console.WriteLine("学号：" + num);
            Console.WriteLine("年龄：" +age);
            Console.WriteLine("性别：" + sex);
            Console.WriteLine("专业信息：" + zhuan);


        }
    }
}
